﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.Security;
using System.ComponentModel.DataAnnotations;

namespace eNoticeMVC.Models
{
    public class UserProfile : ProfileBase
    {
        public string FirstName
        {
            get { return ((string)(base["FirstName"])); }
            set { base["FirstName"] = value; Save(); }
        }

        public string LastName
        {
            get { return ((string)(base["LastName"])); }
            set { base["LastName"] = value; Save(); }
        }

        public string Phone
        {
            get { return ((string)(base["Phone"])); }
            set { base["Phone"] = value; Save();}
        }
       
        public string Address
        {
            get { return ((string)(base["Address"])); }
            set { base["Address"] = value; Save();}
        }
        public static UserProfile GetUserProfile(string username)
        {
            return Create(username) as UserProfile;
        }

        public static UserProfile CurrentUser
        {
            get { return (UserProfile)(ProfileBase.Create(Membership.GetUser().UserName)); }
        }
    }

    public class Profile
    {
        [Required]
        [Display(Name = "First Name")]
        public string FirstName
        {
            get
            {
                return UserProfile.CurrentUser.FirstName;
            }
            set
            {
                UserProfile.CurrentUser.FirstName = value;
            }
        }

        [Required]
        [Display(Name = "Last Name")]
        public string LastName
        {
            get
            {
                return UserProfile.CurrentUser.LastName;
            }
            set
            {
                UserProfile.CurrentUser.LastName = value;
            }
        }

        [Required]
        [Display(Name = "Phone Number")]
        public string Phone
        {
            get
            {
                return UserProfile.CurrentUser.Phone;
            }
            set
            {
                UserProfile.CurrentUser.Phone = value;
            }
        }

        [Required]
        [Display(Name = "Address")]
        public string Address
        {
            get
            {
                return UserProfile.CurrentUser.Address;
            }
            set
            {
                UserProfile.CurrentUser.Address = value;
            }
        }
    }
}